package cn.stylefeng.guns.modular.customer.wrapper;

import cn.stylefeng.guns.modular.customer.entity.Customer;
import cn.stylefeng.guns.modular.customer.entity.Order;
import cn.stylefeng.guns.modular.customer.service.CustomerService;
import cn.stylefeng.guns.modular.customer.service.OrderService;
import cn.stylefeng.roses.core.base.warpper.BaseControllerWrapper;
import cn.stylefeng.roses.core.util.SpringContextHolder;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.commons.lang3.StringUtils;

import java.util.List;
import java.util.Map;

public class RebateWarpper extends BaseControllerWrapper {

    public RebateWarpper(Page<Map<String, Object>> page) {
        super(page);
    }

    //用户
    private CustomerService customerService= SpringContextHolder.getBean(CustomerService.class);
    //订单
    private OrderService orderService= SpringContextHolder.getBean(OrderService.class);


    @Override
    protected void wrapTheMap(Map<String, Object> map) {
        //买人姓名id 用户id
        Integer customerId=(Integer)map.get("customerId");
        //订单id
        Integer orderId=(Integer)map.get("orderId");
        Customer buyer=customerService.getById(customerId);
        Order order =orderService.getById(orderId);
        //买人姓名
        map.put("buyer",buyer.getNickname());
        //订单编号
        map.put("order",order.getOrderNo());
    }
}
